From 79133a09fb76091261c5a2aac1b8bb84432eb02a Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 7 Oct 2005 15:52:43 +0100 Subject: [PATCH] Update kernel watch API to pass the array of watch arguments to the callback instead of just passing the node. This allows us to extend watches to have additional arguments (like domids). Signed-off-by: Anthony Liguori --- .../drivers/xen/balloon/balloon.c | 3 ++- .../drivers/xen/blkback/xenbus.c | 10 ++++++---- .../drivers/xen/blkfront/blkfront.c | 19 ++++++++++++++++--- .../drivers/xen/blktap/xenbus.c | 10 ++++++---- .../drivers/xen/netback/xenbus.c | 10 ++++++---- .../drivers/xen/netfront/netfront.c | 3 ++- .../drivers/xen/tpmback/xenbus.c | 16 ++++++++++++---- .../drivers/xen/tpmfront/tpmfront.c | 4 +++- .../drivers/xen/xenbus/xenbus_probe.c | 10 ++++++---- .../drivers/xen/xenbus/xenbus_xs.c | 2 +- linux-2.6-xen-sparse/include/asm-xen/xenbus.h | 6 +++++- 11 files changed, 65 insertions(+), 28 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c index d720e7d2ea..119315c5e4 100644 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c @@ -351,7 +351,8 @@ static struct xenbus_watch target_watch = }; /* React to a change in the target key */ -static void watch_target(struct xenbus_watch *watch, const char *node) +static void watch_target(struct xenbus_watch *watch, + const char **vec, unsigned int len) { unsigned long long new_target; int err; diff --git a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c index c68e7f545a..187bec8121 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c @@ -55,7 +55,8 @@ static int blkback_remove(struct xenbus_device *dev) } /* Front end tells us frame. */ -static void frontend_changed(struct xenbus_watch *watch, const char *node) +static void frontend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { unsigned long ring_ref; unsigned int evtchn; @@ -64,7 +65,7 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node) = container_of(watch, struct backend_info, watch); /* If other end is gone, delete ourself. */ - if (node && !xenbus_exists(be->frontpath, "")) { + if (vec && !xenbus_exists(be->frontpath, "")) { device_unregister(&be->dev->dev); return; } @@ -143,7 +144,8 @@ again: We provide event channel and device details to front end. Frontend supplies shared frame and event channel. */ -static void backend_changed(struct xenbus_watch *watch, const char *node) +static void backend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { int err; char *p; @@ -195,7 +197,7 @@ static void backend_changed(struct xenbus_watch *watch, const char *node) } /* Pass in NULL node to skip exist test. */ - frontend_changed(&be->watch, NULL); + frontend_changed(&be->watch, NULL, 0); } } diff --git a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c index 0f4f6d0bac..8d6e071fef 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -442,12 +442,16 @@ static struct xenbus_device_id blkfront_ids[] = { { "" } }; -static void watch_for_status(struct xenbus_watch *watch, const char *node) +static void watch_for_status(struct xenbus_watch *watch, + const char **vec, unsigned int len) { struct blkfront_info *info; unsigned int binfo; unsigned long sectors, sector_size; int err; + const char *node; + + node = vec[XS_WATCH_PATH]; info = container_of(watch, struct blkfront_info, watch); node += strlen(watch->node); @@ -652,8 +656,17 @@ static int blkfront_probe(struct xenbus_device *dev, return err; } - /* Call once in case entries already there. */ - watch_for_status(&info->watch, info->watch.node); + { + unsigned int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1; + const char *vec[len]; + + vec[XS_WATCH_PATH] = info->watch.node; + vec[XS_WATCH_TOKEN] = NULL; + + /* Call once in case entries already there. */ + watch_for_status(&info->watch, vec, len); + } + return 0; } diff --git a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c index 4281f7a8b2..b9a5f7a94f 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c @@ -59,7 +59,8 @@ static int blkback_remove(struct xenbus_device *dev) } /* Front end tells us frame. */ -static void frontend_changed(struct xenbus_watch *watch, const char *node) +static void frontend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { unsigned long ring_ref; unsigned int evtchn; @@ -68,7 +69,7 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node) = container_of(watch, struct backend_info, watch); /* If other end is gone, delete ourself. */ - if (node && !xenbus_exists(be->frontpath, "")) { + if (vec && !xenbus_exists(be->frontpath, "")) { xenbus_rm(be->dev->nodename, ""); device_unregister(&be->dev->dev); return; @@ -106,7 +107,8 @@ abort: We provide event channel and device details to front end. Frontend supplies shared frame and event channel. */ -static void backend_changed(struct xenbus_watch *watch, const char *node) +static void backend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { int err; char *p; @@ -129,7 +131,7 @@ static void backend_changed(struct xenbus_watch *watch, const char *node) } /* Pass in NULL node to skip exist test. */ - frontend_changed(&be->watch, NULL); + frontend_changed(&be->watch, NULL, 0); } } diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c index 1e1d27ecaa..c452d7e29f 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c @@ -57,7 +57,8 @@ static int netback_remove(struct xenbus_device *dev) } /* Front end tells us frame. */ -static void frontend_changed(struct xenbus_watch *watch, const char *node) +static void frontend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { unsigned long tx_ring_ref, rx_ring_ref; unsigned int evtchn; @@ -68,7 +69,7 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node) int i; /* If other end is gone, delete ourself. */ - if (node && !xenbus_exists(be->frontpath, "")) { + if (vec && !xenbus_exists(be->frontpath, "")) { xenbus_rm(be->dev->nodename, ""); device_unregister(&be->dev->dev); return; @@ -126,7 +127,8 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node) We provide event channel and device details to front end. Frontend supplies shared frame and event channel. */ -static void backend_changed(struct xenbus_watch *watch, const char *node) +static void backend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { int err; long int handle; @@ -163,7 +165,7 @@ static void backend_changed(struct xenbus_watch *watch, const char *node) kobject_hotplug(&dev->dev.kobj, KOBJ_ONLINE); /* Pass in NULL node to skip exist test. */ - frontend_changed(&be->watch, NULL); + frontend_changed(&be->watch, NULL, 0); } } diff --git a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c index 09a622e7b1..9a2969f5a0 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -963,7 +963,8 @@ static struct xenbus_device_id netfront_ids[] = { { "" } }; -static void watch_for_status(struct xenbus_watch *watch, const char *node) +static void watch_for_status(struct xenbus_watch *watch, + const char **vec, unsigned int len) { } diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c index 48d56745f5..ac31843a2c 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c @@ -59,7 +59,8 @@ static int tpmback_remove(struct xenbus_device *dev) } -static void frontend_changed(struct xenbus_watch *watch, const char *node) +static void frontend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { unsigned long ringref; unsigned int evtchn; @@ -69,7 +70,7 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node) = container_of(watch, struct backend_info, watch); /* If other end is gone, delete ourself. */ - if (node && !xenbus_exists(be->frontpath, "")) { + if (vec && !xenbus_exists(be->frontpath, "")) { xenbus_rm(be->dev->nodename, ""); device_unregister(&be->dev->dev); return; @@ -142,7 +143,8 @@ abort: } -static void backend_changed(struct xenbus_watch *watch, const char *node) +static void backend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { int err; long int instance; @@ -166,6 +168,9 @@ static void backend_changed(struct xenbus_watch *watch, const char *node) be->instance = instance; if (be->tpmif == NULL) { + unsigned int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1; + const char *vec[len]; + be->tpmif = tpmif_find(be->frontend_id, instance); if (IS_ERR(be->tpmif)) { @@ -175,8 +180,11 @@ static void backend_changed(struct xenbus_watch *watch, const char *node) return; } + vec[XS_WATCH_PATH] = be->frontpath; + vec[XS_WATCH_TOKEN] = NULL; + /* Pass in NULL node to skip exist test. */ - frontend_changed(&be->watch, be->frontpath); + frontend_changed(&be->watch, vec, len); } } diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c index b7e041acf4..c6401a1a4a 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c @@ -211,12 +211,14 @@ static int tpm_fe_send_upperlayer(const u8 * buf, size_t count, XENBUS support code **************************************************************/ -static void watch_for_status(struct xenbus_watch *watch, const char *node) +static void watch_for_status(struct xenbus_watch *watch, + const char **vec, unsigned int len) { struct tpmfront_info *info; int err; unsigned long ready; struct tpm_private *tp = &my_private; + const char *node = vec[XS_WATCH_PATH]; info = container_of(watch, struct tpmfront_info, watch); node += strlen(watch->node); diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c index baca05749d..e872df679c 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -562,14 +562,16 @@ static void dev_changed(const char *node, struct xen_bus_type *bus) kfree(root); } -static void frontend_changed(struct xenbus_watch *watch, const char *node) +static void frontend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { - dev_changed(node, &xenbus_frontend); + dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend); } -static void backend_changed(struct xenbus_watch *watch, const char *node) +static void backend_changed(struct xenbus_watch *watch, + const char **vec, unsigned int len) { - dev_changed(node, &xenbus_backend); + dev_changed(vec[XS_WATCH_PATH], &xenbus_backend); } /* We watch for devices appearing and vanishing. */ diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c index 763803297f..d239f6fccc 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c @@ -551,7 +551,7 @@ static int watch_thread(void *unused) vec[XS_WATCH_TOKEN], err); w = find_watch(vec[XS_WATCH_TOKEN]); BUG_ON(!w); - w->callback(w, vec[XS_WATCH_PATH]); + w->callback(w, (const char **)vec, num); kfree(vec); } else if (vec) printk(KERN_WARNING "XENBUS xs_read_watch: %li\n", diff --git a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h index 924a752ac3..821aca1da8 100644 --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h @@ -34,6 +34,9 @@ #include #include +/* FIXME there's got to be a better way to get at the XS_WATCH macros */ +#include + /* A xenbus device. */ struct xenbus_device { char *devicetype; @@ -113,7 +116,8 @@ struct xenbus_watch { struct list_head list; char *node; - void (*callback)(struct xenbus_watch *, const char *node); + void (*callback)(struct xenbus_watch *, + const char **vec, unsigned int len); }; /* notifer routines for when the xenstore comes up */ -- 2.30.2